home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swags_z.zip / STRINGS.SWG / 0071_Misc. String Functions.pas < prev    next >
Pascal/Delphi Source File  |  1994-01-27  |  17KB  |  856 lines

  1. Unit Funcs;
  2.  
  3. (* previously  All_Func.Inc *)
  4.  
  5. (*    05/02/1988     J Tal
  6.                      Rollins Medical/Dental Systems
  7.         
  8.                      Public Domain
  9. *)
  10.  
  11.  
  12. Interface
  13.   Uses Dos,Crt;
  14.  
  15.  
  16.   TYPE
  17.     st255 = string[255];
  18.  
  19.   Function Word_Int(r: REAL) : INTEGER;
  20.  
  21.   Function Word_Real(i: INTEGER) : REAL;
  22.  
  23.   Function Real_Mod(a,b: REAL) : REAL;
  24.     (*  modulus for two real numbers  
  25.  
  26.         Real_Mod(15.0,2.0)  =  1.0
  27.  
  28.     *)
  29.  
  30.   function lowcase(c : char) : char;
  31.     (*  opposite of upcase 
  32.  
  33.         lowcase('A') = 'a'
  34.         lowcase('b') = 'b'
  35.         
  36.     *)
  37.  
  38.   function f_buf_conv( x : st255) : st255;
  39.     (*  convert a file buffer into a string *)
  40.  
  41.   procedure prog_chain(prog : st255); (* dummy *)
  42.  
  43.   function spaces(num : integer) : st255;
  44.     (*  like basic space$ 
  45.  
  46.         spaces(10) = '          '
  47.  
  48.     *)
  49.  
  50.   function bakfile( name : st255) : st255;
  51.     (*  takes filename and returns .BAK version of that name 
  52.  
  53.         bakfile('test.dat')  = 'test.bak'
  54.  
  55.     *)
  56.  
  57.   function bool(x : boolean) : integer;
  58.     (*  True becomes -1, False becomes 0 
  59.  
  60.         bool(true) = -1
  61.         bool(false) = 0
  62.  
  63.     *)
  64.  
  65.   function center ( line : st255) : integer;
  66.     (*  returns x location to print the line/string at to center it 
  67.  
  68.         center('HELP') = 38
  69.         gotoxy(center(message),y);  write(message);
  70.  
  71.  
  72.     *)      
  73.  
  74.   function fill(n,char : integer) : st255;
  75.     (*  fill string to n characters with chr(char)  
  76.         like basic string$  
  77.  
  78.         fill(10,65) = 'AAAAAAAAAA'
  79.  
  80.     *)
  81.  
  82.   function fnline( curline : st255) : st255;
  83.     (*  isolate leading number from a line 
  84.  
  85.         fnline('255  IF X = 255 THEN GOTO')  = 255
  86.  
  87.     *)
  88.  
  89.   function fnmax(a,b : integer) : integer;
  90.     (*   max of two integers 
  91.  
  92.          fnmax(4,5) = 5
  93.  
  94.     *)
  95.  
  96.   function fnmin(a,b : integer) : integer;
  97.     (*   min of two integers
  98.  
  99.          fnmin(-9,5) = -9
  100.  
  101.     *)
  102.  
  103.   function lpad(ch : st255; num : integer) : st255;
  104.     (*   left pad the string ch with spaces to num length 
  105.  
  106.  
  107.          lpad('HELP',10) = '      HELP'
  108.  
  109.    *)
  110.  
  111.   function ltrm ( curline : st255) : st255;
  112.     (*   remove leading spaces from curline  
  113.  
  114.          ltrm('        HELP') = 'HELP'
  115.  
  116.     *)
  117.  
  118.   function peek(seg,ofs : integer) : integer;
  119.     (*   like basic peek 
  120.  
  121.          x := peek(segment,offset);
  122.     
  123.     *)
  124.  
  125.   procedure poke(seg,ofs,v : integer);
  126.     (*   like basic poke  
  127.  
  128.          poke(screen_seg,ofs,character)
  129.  
  130.     *)
  131.  
  132.   function power(x,n : integer) : integer;
  133.     (*   x^n
  134.  
  135.           power(2,4) = 16
  136.  
  137.     *)
  138.  
  139.   function rpad(ch : st255; num : integer) : st255;
  140.     (*   right pad ch to num length with spaces  
  141.  
  142.          rpad('THIS',10) = 'THIS      '
  143.  
  144.     *)
  145.  
  146.   function rpt(num,ch : integer) : st255;
  147.     (*   like basic string$  
  148.  
  149.          rpt(10,67) = 'CCCCCCCCCC'
  150.  
  151.     *)
  152.  
  153.   function rtrm(ch : st255) : st255;
  154.     (*    remove trailing spaces from string ch 
  155.  
  156.           rtrm('ROYAL    ') = 'ROYAL'
  157.  
  158.     *)
  159.  
  160.   function srep(ch,dh,eh : st255): st255;
  161.     (*    srep=string replace
  162.           replace all occurances of string dh with eh in string ch  
  163.  
  164.  
  165.           srep('THE CAT','CAT','FAT') = 'THE FAT'
  166.  
  167.     *)
  168.   
  169.   procedure s_swap(var a1,a2 : st255);
  170.     (*    string swap, swap a1 & a2 
  171.  
  172.           a1 = 'MAMA'
  173.           a2 = 'DADDY'
  174.  
  175.           s_swap(a1,a2)
  176.  
  177.           a1 = 'DADDY'
  178.           a2 = 'MAMA'
  179.  
  180.     *)
  181.  
  182.   function fnxtrm( s : st255) : st255;
  183.     (*    if string s is all blanks, then returns '' null string 
  184.  
  185.            fnxtrm('      g   ') = ' '
  186.            fnxtrm('          ') = ''
  187.  
  188.     *)
  189.  
  190.   function fnval( curline : st255) : integer;
  191.     (*    converts string representation of number to integer 
  192.  
  193.           fnval('123 ') = 123
  194.  
  195.     *)
  196.  
  197.   function fns ( a1 : integer) : st255;
  198.     (*   converts integer to string representation  
  199.  
  200.          fns(1234) = '1234'
  201.  
  202.    *)
  203.  
  204.   function left_str( curline : st255; i : integer) : st255;
  205.     (*   take i characters from curline starting at the left 
  206.  
  207.          left_str('THE QUICK BROWN',9) = 'THE QUICK'
  208.  
  209.     *)
  210.  
  211.   function right_str( curline : st255; i : integer) : st255;
  212.     (*   take i characters from curline starting at the right 
  213.  
  214.          right_str('THE QUICK BROWN',9) = 'ICK BROWN'
  215.     *)
  216.  
  217.   procedure mid_str_assign( var modify_string : st255; s_start,s_len : integer; ins_string : st255);
  218.     (*   mid string assignment
  219.          mid_str_assign('flemish',1,2,'bl') = 'blemish';  
  220.                                   ^ starting a character 1
  221.                                     ^ for a length of two 
  222.                                        ^ make those chars 'bl'
  223.  
  224.          mid_str_assign('abcdefg',2,2,'BC') = 'aBCdefg'
  225.     *)
  226.    
  227.   function hex_str(hex: INTEGER) : st255;
  228.      (*  hexadecimal string representation of decimal integer 
  229.  
  230.          hex_str(123) = '7B'
  231.  
  232.      *)
  233.  
  234.   function hex_val(hex: st255) : INTEGER;
  235.      (*  reverse of hex_str,  integer representation of hexadecimal string 
  236.  
  237.          hex_val('7B') = 123
  238.  
  239.      *)
  240.  
  241.   function bin_str(bin: INTEGER) : st255;
  242.      (*  binary string representation of integer  
  243.  
  244.          bin_str(123) = '1111011';
  245.      *)
  246.  
  247.   FUNCTION InKey(VAR Special : BOOLEAN; VAR Keychar : CHAR) : BOOLEAN;
  248.      (*  checks for keypressed, returns type and character *)
  249.  
  250.   function fnzero (num : st255 ; places : integer) : st255;
  251.      (*  left '0' pad a number into a string 
  252.  
  253.          fnzero('123',10) = '0000000123'
  254.  
  255.      *)
  256.  
  257.   function fns_z(n : integer) : st255;
  258.      (*  left '0' pad a number into a 2 digit string 
  259.  
  260.            fns_z(1) = '01'
  261.          fns_z(45) = '45'
  262.      *)
  263.  
  264.   Function bit_blast(bit_stream: st255) : INTEGER;
  265.      (*  reverse of bin_str, integer representation of binary string 
  266.  
  267.          bit_blast('1110001') = 113
  268.      *)
  269.  
  270.   Function printusing (mask : st255; number : real) : st255;
  271.      (*
  272.  
  273.              printusing('###,###.##',19.95) = '     19.95'
  274.            printusing('###,###.##CR,-19.95) = '     19.95CR'
  275.  
  276.      *)
  277.  
  278.  
  279.   Procedure UpStr(VAR a: st255);
  280.      (*  Upcase a whole string 
  281.  
  282.          UpStr('The cat Mildred') = 'THE CAT MILDRED'
  283.  
  284.      *)
  285.  
  286.  
  287.  
  288. Implementation
  289.  
  290.  
  291.  
  292.  
  293. Function Word_Int;
  294. (*  (r: REAL) : INTEGER; *)
  295.  
  296. BEGIN  
  297.   IF r > 32767.0 THEN
  298.     Word_int := Trunc(r - 65536.0)
  299.   ELSE
  300.     Word_int := Trunc(r);
  301. END;
  302.  
  303.  
  304. Function Word_Real;
  305. (* (i: INTEGER) : REAL; *)
  306. BEGIN
  307.   IF i < 0 THEN
  308.     Word_Real := i + 32767.0
  309.   ELSE
  310.     Word_Real := i;
  311. END;
  312.  
  313.  
  314. Function Real_Mod;
  315. (*  (a,b: REAL) : REAL; *)
  316. BEGIN
  317.   WHILE a > b DO begin
  318.      a := a - b;
  319.   END;
  320.   Real_Mod := a;
  321. END; (* Real_Mod *)
  322.  
  323.  
  324. function lowcase;
  325. (* (c : char) : char; *)
  326. var
  327. c1 : integer;
  328. begin
  329. c1 := ord(c);
  330.  if (c1 > 64) and (c1 < 91)  {only change A-Z to a-z}
  331.   then
  332.    c1 := c1 + 32;
  333. lowcase := chr(c1);
  334. end;
  335.  
  336.  
  337. function f_buf_conv;
  338. (*  ( x : st255) : st255; *)
  339. var
  340.  i : integer;
  341.  temp : st255;
  342. begin
  343.  temp := '';
  344.  temp := x[0] + copy(x,1,length(x));
  345.  f_buf_conv := temp;
  346. end;
  347.  
  348.  
  349. procedure prog_chain;
  350. (* (prog : st255); *) (* dummy *) 
  351. begin
  352. halt;
  353. end;
  354.  
  355.  
  356. function spaces;
  357. (* (num : integer) : st255; *)
  358.   var
  359.     sp1 : integer;
  360.     space : st255;
  361.   begin
  362.     space := '';
  363.     for sp1 := 1 to num do
  364.         space := space + ' ';
  365.     spaces := space;
  366.   end;
  367.  
  368.   { ------------------- }
  369.  
  370. function bakfile;
  371. (* ( name : st255) : st255; *)
  372. var
  373.   a1 : integer;
  374. begin
  375.   a1 := pos('.',name);
  376.   if a1 = 0 then
  377.     bakfile := name + '.BAK'
  378.    else
  379.   bakfile := copy(name,1,a1) + 'BAK';
  380. end;
  381.  
  382.   { ------------------- }
  383.  
  384. function bool;
  385. (* (x : boolean) : integer; *)
  386. begin
  387.    if x then bool := -1
  388.       else bool := 0
  389. end;
  390.  
  391.   { ------------------- }
  392.  
  393. function center;
  394. (*  ( line : st255) : integer; *)
  395. var
  396.   a1 : integer;
  397. begin
  398.   a1 := length(line);
  399.   center := trunc(39-(a1 div 2));
  400. end;
  401.  
  402.   { ------------------- }
  403.  
  404. function fill;
  405. (* (n,char : integer) : st255; *)
  406. var i : integer;
  407. begin
  408.     for i := 1 to n do
  409.         fill[i] := chr(char)
  410. end;
  411.  
  412.   { ------------------- }
  413.  
  414. function fnline;
  415. (*  ( curline : st255) : st255; *)
  416. var
  417. a1 : integer;
  418. a1s : st255;
  419. begin
  420.  a1 := pos(' ',curline);
  421.  a1s := copy(curline,1,a1);
  422.  fnline := a1s;
  423. end;
  424.  
  425.   { ------------------- }
  426.  
  427. function fnmax;
  428. (* (a,b : integer) : integer; *)
  429. begin
  430.    fnmax := a-bool(b>a)*(b-a)
  431. end;
  432.  
  433.   { ------------------- }
  434.  
  435. function fnmin;
  436. (* (a,b : integer) : integer; *)
  437. begin
  438.    fnmin := a+bool(a>b)*(a-b)
  439. end;
  440.  
  441.   { ------------------- }
  442.  
  443. function lpad;
  444. (* (ch : st255; num : integer) : st255; *)
  445.   var
  446.     sp1 : integer;
  447.     sp2 : integer;
  448.   begin
  449.     sp1 := length(ch);
  450.     sp2 := num - sp1;
  451.     lpad := spaces(sp2) + ch;
  452.   end;
  453.  
  454.   { ------------------- }
  455.  
  456. function ltrm;
  457. (*  ( curline : st255) : st255; *)
  458. begin
  459.  while curline[1] = ' ' do
  460.   curline := copy(curline,2,255);
  461. ltrm := curline;
  462. end;
  463.  
  464.   { ------------------- }
  465.  
  466. function peek;
  467. (* (seg,ofs : integer) : integer; *)
  468. begin
  469.  peek := mem[seg:ofs];
  470. end;
  471.  
  472.   { ------------------- }
  473.  
  474. procedure poke;
  475. (* (seg,ofs,v : integer); *)
  476. begin
  477.  mem[seg:ofs] := v;
  478. end;
  479.  
  480.   { ------------------- }
  481.  
  482. function power;
  483. (* (x,n : integer) : integer; *)
  484. begin
  485.    if n = 1
  486.       then power := x
  487.       else power := x*power(x,n-1)
  488. end;
  489.  
  490.  
  491.   { ------------------- }
  492.  
  493. function rpad;
  494. (* (ch : st255; num : integer) : st255;        *)
  495.   begin
  496.     rpad := copy(ch + spaces(num),1,num);
  497.   end;
  498.  
  499.   { ------------------- }
  500.  
  501. function rpt;
  502. (* (num,ch : integer) : st255; *)
  503.   var
  504.     sp1 : integer;
  505.     space : st255;
  506.   begin
  507.     space := '';
  508.     for sp1 := 1 to num do
  509.         space := space + chr(ch);
  510.     rpt := space;
  511.   end;
  512.  
  513.   { ------------------- }
  514.  
  515. function rtrm;
  516. (* (ch : st255) : st255; *)
  517.   var
  518.     sp1 : integer;
  519.     sp2 : integer;
  520.   begin
  521.     sp1 := length(ch);
  522.     sp2 := sp1;
  523.     while (ch[sp2] = ' ') and (sp2 <> 0) do
  524.         sp2 := sp2 - 1;
  525.     rtrm := copy(ch,1,sp2);
  526.   end;
  527.  
  528.   { ------------------- }
  529.  
  530.  
  531. function srep;
  532. (* (ch,dh,eh : st255): st255; *)
  533.   var
  534.     sp1 : integer;
  535.     sp2 : integer;
  536.     sp3 : integer;
  537.     sp4 : integer;
  538.     sp5 : integer;
  539.     atemp : st255;
  540.     btemp : st255;
  541.     ctemp : st255;
  542.   begin
  543.     sp1 := length(ch);
  544.     sp2 := length(dh);
  545.     sp3 := length(eh);
  546.     while pos(dh,ch) <> 0 do
  547.     begin
  548.       sp4 := pos(dh,ch);
  549.       sp5 := sp1 - (sp4 + sp2) + 1;
  550.          atemp := copy(ch,1,sp4-1);
  551.          btemp := copy(ch,sp4+sp2,sp5);
  552.          ctemp := atemp + eh + btemp;
  553.          ch := ctemp;
  554.    end;
  555. srep := ch;
  556. end;
  557.  
  558.   { ------------------- }
  559.  
  560. procedure s_swap;
  561. (* (var a1,a2 : st255);        *)
  562. var
  563.   temp : st255;
  564. begin
  565.   temp := a1;
  566.   a1 := a2;
  567.   a2 := temp;
  568. end;
  569.  
  570.   { ------------------- }
  571.  
  572. function fnxtrm;
  573. (* ( s : st255) : st255; *)
  574.  begin
  575.   fnxtrm := spaces(1+bool(s = spaces(length(s))))
  576.  end;
  577.  
  578.   { ------------------- }
  579.  
  580. function fnval;
  581. (* ( curline : st255) : integer; *)
  582. var
  583.  err,a1 : integer;
  584. begin
  585.  while copy(curline,1,1) = '' do
  586.    curline := copy(curline,2,255);
  587.  val(curline,a1,err);
  588.  fnval := a1;
  589. end;
  590.  
  591.   { ------------------- }
  592.  
  593. function fns;
  594. (* ( a1 : integer) : st255; *)
  595. var
  596.  a1s : st255;
  597. begin
  598.  str(a1,a1s);
  599.  fns := a1s;
  600. end;
  601.  
  602. function left_str;
  603. (* ( curline : st255; i : integer) : st255; *)
  604. begin
  605.  left_str := copy(curline,1,i);
  606. end;
  607.  
  608.   { ------------------- }
  609.  
  610. function right_str;
  611. (* ( curline : st255; i : integer) : st255; *)
  612. var
  613.  l : integer;
  614. begin
  615.  l := length(curline);
  616.  right_str := copy(curline,l-i+1,i);
  617. end;
  618.  
  619.   { ------------------- }
  620.  
  621. {
  622.  format for mid_str_assign
  623.  
  624.  basic - mid$(s$,12,12) = mid$(f$,4,12)
  625.  
  626.  pascal -  mid_str_assign(s_str,12,12,copy(f_str,4,12));
  627.         or
  628.            mid_str_assign(s_str,12,12,'123456789012');
  629. }
  630.  
  631.   { ------------------- }
  632.  
  633. procedure mid_str_assign;
  634. (* ( var modify_string : st255; s_start,s_len : integer; ins_string : st255); *)
  635. begin
  636.   delete(modify_string,s_start,s_len);
  637.   insert(ins_string,modify_string,s_start);
  638. end;
  639.  
  640.   { ------------------- }
  641.  
  642. function hex_str(hex: INTEGER) : st255;
  643. VAR
  644.   hex_out: st255;
  645.   hex_temp: INTEGER;
  646.   hex_mas: st255;
  647. BEGIN
  648.   hex_mas := '0123456789ABCDEF';
  649.   hex_out := '';
  650.   WHILE hex > 0 DO begin
  651.     hex_temp := hex AND 15;
  652.     hex_out := hex_mas[hex_temp+1] + hex_out;
  653.     hex := hex DIV 16;
  654.   END;
  655.   FOR hex_temp := 1 to 2 DO begin
  656.     IF length(hex_out) < 2 then hex_out := '0' + hex_out;
  657.   END;
  658.   hex_str := hex_out;
  659. END;
  660.  
  661.   { ------------------- }
  662.  
  663. function hex_val;
  664. (* (hex: st255) : INTEGER; *)
  665. VAR
  666.   hex_out: INTEGER;
  667.   hex_temp: INTEGER;
  668.   hex_mas: st255;
  669. BEGIN
  670.   hex_mas := '0123456789ABCDEF';
  671.   hex_out := 0;
  672.   WHILE length(hex) > 0 DO begin
  673.     hex_temp := Pos(hex[1],hex_mas);
  674.     hex_out := hex_out * 16 + (hex_temp)-1;
  675.     hex := copy(hex,2,255);
  676.   END;
  677.   hex_val := hex_out;
  678. END;
  679.  
  680.   { ----------------- }
  681.  
  682. function bin_str;
  683. (* (bin: INTEGER) : st255; *)
  684. VAR
  685.   bin_out: st255;
  686.   bin_temp: INTEGER;
  687. BEGIN
  688.   bin_out := '';
  689.   WHILE bin <> 0 DO begin
  690.     bin_temp := bin AND 1;
  691.     IF bin_temp = 1 THEN
  692.        bin_out := '1' + bin_out
  693.     ELSE
  694.        bin_out := '0' + bin_out;
  695.  
  696.     bin := bin shr 1;
  697.   END;
  698.   bin_str := bin_out;
  699. END;
  700.  
  701.   { ------------------- }
  702.  
  703. FUNCTION InKey;
  704. (* (VAR Special : BOOLEAN; VAR Keychar : CHAR) : BOOLEAN; *)
  705. VAR
  706.   Dosrec : Dos.Registers;
  707. BEGIN
  708.   IF Crt.KeyPressed THEN begin
  709.         Dosrec.AX := $0800;
  710.         MSDOS(DosRec);
  711.         KEYCHAR := CHR(LO(DOSREC.AX));
  712.         INKEY := TRUE;
  713.         IF ORD(KEYCHAR) = 0
  714.            THEN
  715.               BEGIN
  716.                 SPECIAL := TRUE;
  717.                 DOSREC.AX := $0800;
  718.                 MSDOS(DosRec);
  719.                 KEYCHAR := CHR(LO(DOSREC.AX));
  720.               END
  721.             ELSE SPECIAL := FALSE;
  722.        END
  723.       ELSE
  724.       BEGIN
  725.         INKEY := FALSE;
  726.         SPECIAL := FALSE;
  727.       END;
  728.  END;
  729.  
  730.   { ------------------- }
  731.  
  732. function fnzero;
  733. (* (num : st255 ; places : integer) : st255; *)
  734. var
  735.  a1s : st255;
  736.  a1 : integer;
  737. begin
  738.  a1 := length(num);
  739.  a1s := rpt(places-a1,48) + num;
  740.  fnzero := a1s;
  741. end;
  742.  
  743.   { ------------------- }
  744.  
  745.  
  746. function fns_z;
  747. (* (n : integer) : st255; *)
  748. var
  749.  c : st255;
  750. begin
  751.   c := fns(n);
  752.   if length(c) = 1
  753.    then
  754.     c := '0' + c;
  755.   fns_z := c;
  756. end;
  757.  
  758.   { ------------------- }
  759.  
  760. Function bit_blast;
  761. (* (bit_stream: st255) : INTEGER; *)
  762.  (* convert string representation of bits into integer: '1001' becomes 9 *)
  763. VAR
  764.   i,bit_box : INTEGER;
  765. BEGIN
  766.   bit_box := 0;
  767.   FOR i := Length(bit_stream) DOwnTO 1 DO  BEGIN
  768.     IF bit_stream[i] = '1' THEN begin
  769.        bit_box := bit_box + (1 shl ((Length(bit_stream) - i)));
  770.     END;
  771.   END;
  772.   bit_blast := bit_box;
  773. END;
  774.  
  775.   { ------------------- }
  776.  
  777. Function printusing;
  778. (* (mask : st255; number : real) : st255; *)
  779.  
  780. const
  781.      comma : char = ',';
  782.      point : char = '.';
  783.      minussign : char = '-';
  784.  
  785. VAR
  786.      fieldwidth, IntegerLength, i, j, places,pointposition : INTEGER;
  787.      usingcommas, decimal, negative : boolean;
  788.      outstring, IntegerString       : string[80];
  789.  
  790. BEGIN
  791.      negative    := number < 0;
  792.      number      := abs(number);
  793.      places      := 0;
  794.      if pos('CR',mask) = 0
  795.       then
  796.         fieldwidth  := length(mask)
  797.       else
  798.         fieldwidth := length(mask) - 2;
  799.  
  800.      usingcommas := pos(comma,mask) > 0;
  801.      decimal     := pos(point,mask) > 0;
  802.  
  803.      if decimal then
  804.           BEGIN
  805.               pointposition := pos(point,mask);
  806.               places        := fieldwidth - pointposition
  807.               END;
  808.      str( number : 0 : places, outstring);
  809.  
  810.      if usingcommas then
  811.          BEGIN
  812.               j := 0;
  813.               IntegerString := copy(outstring, 1, length( outstring ) - places );
  814.               IntegerLength := length( IntegerString );
  815.               if decimal then
  816.                    IntegerLength := IntegerLength -1;
  817.               FOR i := IntegerLength DOwnto 2 DO
  818.                    BEGIN
  819.                      j := j + 1;
  820.                      if j mod 3 = 0 then
  821.                           insert ( comma, outstring, i )
  822.                    end
  823.               END;
  824.  
  825.  
  826.     if length(outstring) < fieldwidth
  827.       then
  828.         outstring := spaces(fieldwidth - length(outstring)) + outstring;
  829.  
  830.      if (negative)
  831.       then
  832.        if (pos('CR',mask) <> 0)
  833.         then
  834.           outstring := outstring + 'CR'
  835.         else
  836.           outstring := minussign + outstring;
  837.  
  838.  
  839.     printusing := outstring;
  840.  
  841.  
  842. END; (* printusing *)
  843.  
  844.  
  845. Procedure UpStr;
  846. VAR
  847.   i : Integer;
  848. BEGIN
  849.   For i := 1 TO Length(a) DO
  850.      a[i] := UpCase(a[i]);
  851.  
  852. END;
  853.  
  854. END.
  855.  
  856.